package com.heima.wemedia.controller.v1;


import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wmUser.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "自媒体用户")
@RestController
@RequestMapping("/api/v1/user")
public class VmUserController {
    @Autowired
    private WmUserService wmUserService;

    @ApiOperation("根据用户名查询自媒体用户")
    @GetMapping("/findByName/{name}")
    public ResponseResult findWmUserByName(@PathVariable("name") String name) {
        return wmUserService.findWmUserByName(name);
    }

    @ApiOperation("保存自媒体用户")
    @PostMapping("/save")
    public ResponseResult addWmUser(@RequestBody WmUser wmUser) {
        return wmUserService.addWmUser(wmUser);
    }

    @ApiOperation("根据id查询自媒体用户信息")
    @GetMapping("/findOne/{id}")
    public ResponseResult<WmUser> findWmUserById(@PathVariable("id") Integer id) {
        return ResponseResult.okResult(wmUserService.getById(id));
    }
}
